package service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import bean.User;
import dao.UserDAO;
import service.UserService;

import java.util.List;

@Service("service")
public class UserServiceImpl implements UserService {
    private final UserDAO dao;

    @Autowired
    public UserServiceImpl(UserDAO dao) {
        this.dao = dao;
    }

    @Transactional
    public boolean add(User temp) {
        return dao.add(temp);
    }

    @Transactional
    public boolean modify(User temp) {
        return dao.mod(temp);
    }

    @Transactional
    public boolean remove(int id) {
        return dao.rem(id);
    }

    public User query(int id) {
        return dao.selById(id);
    }

    public List<User> query(User temp) {
        return dao.selByOthers(temp);
    }
}
